package com.haosheng.testproject;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.haosheng.testproject.ui.BaseActivity;
import com.haosheng.testproject.utils.HttpConstants;
import com.haosheng.testproject.utils.HttpSuccess;

public class MainActivity extends BaseActivity {
    
    private TextView mTv1;
    private TextView mTv2;
    private TextView mTv3;
    private Button mBtn1;
    private Button mBtn2;
    private Button mBtn3;
    private Button mBtnError;
    
    @Override
    public View getContent() {
        View view = LayoutInflater.from(this).inflate(R.layout.activity_test, null);
        mTv1 = view.findViewById(R.id.tv_1);
        mTv2 = view.findViewById(R.id.tv_2);
        mTv3 = view.findViewById(R.id.tv_3);
        mBtn1 = view.findViewById(R.id.btn_1);
        mBtn2 = view.findViewById(R.id.btn_2);
        mBtn3 = view.findViewById(R.id.btn_3);
        mBtnError = view.findViewById(R.id.btn_error);
        return view;
    }
    
    /**
     * 后面你想干什么
     */
    @Override
    protected void next() {
        mTv1.setVisibility(View.INVISIBLE);
        mTv2.setVisibility(View.INVISIBLE);
        mTv3.setVisibility(View.INVISIBLE);
        mBtn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mTv1.getVisibility() == View.VISIBLE) {
                    mTv1.setVisibility(View.INVISIBLE);
                } else {
                    mTv1.setVisibility(View.VISIBLE);
                }
            }
        });
        mBtn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mTv2.getVisibility() == View.VISIBLE) {
                    mTv2.setVisibility(View.INVISIBLE);
                } else {
                    mTv2.setVisibility(View.VISIBLE);
                }
                httpGet(HttpConstants.YOUDAO, new HttpSuccess() {
                    @Override
                    public void httpSuccess(String str) {
                        dLog(str);
                    }
                });
            }
        });
        
        mBtn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mTv3.getVisibility() == View.VISIBLE) {
                    mTv3.setVisibility(View.INVISIBLE);
                } else {
                    mTv3.setVisibility(View.VISIBLE);
                }
                httpGet(HttpConstants.SOUGOU, new HttpSuccess() {
                    @Override
                    public void httpSuccess(String str) {
                        dLog(str);
                    }
                });
                
                
            }
        });
        mBtnError.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                toggleContentVisible();
                httpGet(HttpConstants.BAIDU, new HttpSuccess() {
                    @Override
                    public void httpSuccess(String str) {
                        dLog(str);
                    }
                });
            }
        });
    }
    
}
